﻿using System;
using System.Linq;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace agree.itsdb
{
	using Type = System.Type;

	public class PrimaryKeyAttribute : Attribute
	{
	};

	public class ExternalKeyAttribute : Attribute
	{
		/// <summary>
		/// type of item in an external table which has a primary key with the matching name as the field 
		/// decorated with this attribute
		/// </summary>
		public Type ti_ext;

		/// <param name="ti_ext">
		/// type of item in an external table which has a primary key with the matching name as the field 
		/// decorated with this attribute
		/// </param>
		public ExternalKeyAttribute(Type ti_ext)
		{
			this.ti_ext = ti_ext;
		}
	};

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// Abstract base class for Itsdb item types
	/// </summary>
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	public abstract class entity : identity_propchange, IEditableObject
	{
		public entity(TsdbTable tb)
			: base(tb)
		{
		}

		public void BeginEdit()
		{
		}

		public void CancelEdit()
		{
		}

		public void EndEdit()
		{
		}

		//public override string ToString()
		//{
		//	//var a = this.GetType().GetCustomAttributesData().FirstOrDefault(x => typeof(DebuggerDisplayAttribute).IsAssignableFrom(x.AttributeType));
		//	return base.ToString();
		//}

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// 
		/// Item classes follow
		///
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		[DebuggerDisplay("{_i_id.ToString(),nq} {_i_input,nq}")]
		public class Item : entity, IString
		{
			public Item(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _i_id;
			string _i_origin;
			string _i_register;
			string _i_format;
			int _i_difficulty;
			string _i_category;
			string _i_input;
			string _i_tokens;
			string _i_gloss;
			string _i_translation;
			int _i_wf;
			int _i_length;
			string _i_comment;
			string _i_author;
			DateTime _i_date;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String Text
			{
				get { return _i_input; }
				set { _i_input = value; }
			}

			public long Id { get { return _i_id; } }
			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_id
			{
				get { return _i_id; }
				set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_origin
			{
				get { return _i_origin; }
				set { if (value != _i_origin) { _i_origin = value; NotifyPropertyChanged("i_origin"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_register
			{
				get { return _i_register; }
				set { if (value != _i_register) { _i_register = value; NotifyPropertyChanged("i_register"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_format
			{
				get { return _i_format; }
				set { if (value != _i_format) { _i_format = value; NotifyPropertyChanged("i_format"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_difficulty
			{
				get { return _i_difficulty; }
				set { if (value != _i_difficulty) { _i_difficulty = value; NotifyPropertyChanged("i_difficulty"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_category
			{
				get { return _i_category; }
				set { if (value != _i_category) { _i_category = value; NotifyPropertyChanged("i_category"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_input
			{
				get { return _i_input; }
				set { if (value != _i_input) { _i_input = value; NotifyPropertyChanged("i_input"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_tokens
			{
				get { return _i_tokens; }
				set { if (value != _i_tokens) { _i_tokens = value; NotifyPropertyChanged("i_tokens"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_gloss
			{
				get { return _i_gloss; }
				set { if (value != _i_gloss) { _i_gloss = value; NotifyPropertyChanged("i_gloss"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_translation
			{
				get { return _i_translation; }
				set { if (value != _i_translation) { _i_translation = value; NotifyPropertyChanged("i_translation"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_wf
			{
				get { return _i_wf; }
				set { if (value != _i_wf) { _i_wf = value; NotifyPropertyChanged("i_wf"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_length
			{
				get { return _i_length; }
				set { if (value != _i_length) { _i_length = value; NotifyPropertyChanged("i_length"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_comment
			{
				get { return _i_comment; }
				set { if (value != _i_comment) { _i_comment = value; NotifyPropertyChanged("i_comment"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String i_author
			{
				get { return _i_author; }
				set { if (value != _i_author) { _i_author = value; NotifyPropertyChanged("i_author"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime i_date
			{
				get { return _i_date; }
				set { if (value != _i_date) { _i_date = value; NotifyPropertyChanged("i_date"); } }
			}
		};


		public class Analysis : entity
		{
			public Analysis(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Item))]
			int _i_id;
			string _a_position;
			string _a_instance;
			string _a_category;
			string _a_function;
			string _a_domain;
			string _a_tag;
			string _a_comment;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_id
			{
				get { return _i_id; }
				set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String a_position
			{
				get { return _a_position; }
				set { if (value != _a_position) { _a_position = value; NotifyPropertyChanged("a_position"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String a_instance
			{
				get { return _a_instance; }
				set { if (value != _a_instance) { _a_instance = value; NotifyPropertyChanged("a_instance"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String a_category
			{
				get { return _a_category; }
				set { if (value != _a_category) { _a_category = value; NotifyPropertyChanged("a_category"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String a_function
			{
				get { return _a_function; }
				set { if (value != _a_function) { _a_function = value; NotifyPropertyChanged("a_function"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String a_domain
			{
				get { return _a_domain; }
				set { if (value != _a_domain) { _a_domain = value; NotifyPropertyChanged("a_domain"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String a_tag
			{
				get { return _a_tag; }
				set { if (value != _a_tag) { _a_tag = value; NotifyPropertyChanged("a_tag"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String a_comment
			{
				get { return _a_comment; }
				set { if (value != _a_comment) { _a_comment = value; NotifyPropertyChanged("a_comment"); } }
			}
		};


		public class Phenomenon : entity
		{
			public Phenomenon(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _p_id;
			string _p_name;
			string _p_supertypes;
			string _p_presupposition;
			string _p_interaction;
			string _p_purpose;
			string _p_restrictions;
			string _p_comment;
			string _p_author;
			DateTime _p_date;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int p_id
			{
				get { return _p_id; }
				set { if (value != _p_id) { _p_id = value; NotifyPropertyChanged("p_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_name
			{
				get { return _p_name; }
				set { if (value != _p_name) { _p_name = value; NotifyPropertyChanged("p_name"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_supertypes
			{
				get { return _p_supertypes; }
				set { if (value != _p_supertypes) { _p_supertypes = value; NotifyPropertyChanged("p_supertypes"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_presupposition
			{
				get { return _p_presupposition; }
				set { if (value != _p_presupposition) { _p_presupposition = value; NotifyPropertyChanged("p_presupposition"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_interaction
			{
				get { return _p_interaction; }
				set { if (value != _p_interaction) { _p_interaction = value; NotifyPropertyChanged("p_interaction"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_purpose
			{
				get { return _p_purpose; }
				set { if (value != _p_purpose) { _p_purpose = value; NotifyPropertyChanged("p_purpose"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_restrictions
			{
				get { return _p_restrictions; }
				set { if (value != _p_restrictions) { _p_restrictions = value; NotifyPropertyChanged("p_restrictions"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_comment
			{
				get { return _p_comment; }
				set { if (value != _p_comment) { _p_comment = value; NotifyPropertyChanged("p_comment"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_author
			{
				get { return _p_author; }
				set { if (value != _p_author) { _p_author = value; NotifyPropertyChanged("p_author"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime p_date
			{
				get { return _p_date; }
				set { if (value != _p_date) { _p_date = value; NotifyPropertyChanged("p_date"); } }
			}
		};


		public class Parameter : entity
		{
			public Parameter(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Item_Phenomenon))]
			int _ip_id;
			string _position;
			string _attribute;
			string _value;
			string _instance;
			string _pa_comment;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int ip_id
			{
				get { return _ip_id; }
				set { if (value != _ip_id) { _ip_id = value; NotifyPropertyChanged("ip_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String position
			{
				get { return _position; }
				set { if (value != _position) { _position = value; NotifyPropertyChanged("position"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String attribute
			{
				get { return _attribute; }
				set { if (value != _attribute) { _attribute = value; NotifyPropertyChanged("attribute"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String value
			{
				get { return _value; }
				set { if (value != _value) { _value = value; NotifyPropertyChanged("value"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String instance
			{
				get { return _instance; }
				set { if (value != _instance) { _instance = value; NotifyPropertyChanged("instance"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String pa_comment
			{
				get { return _pa_comment; }
				set { if (value != _pa_comment) { _pa_comment = value; NotifyPropertyChanged("pa_comment"); } }
			}
		};


		public class Set : entity
		{
			public Set(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _s_id;
			[ExternalKey(typeof(Phenomenon))]
			int _p_id;
			string _s_author;
			DateTime _s_date;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int s_id
			{
				get { return _s_id; }
				set { if (value != _s_id) { _s_id = value; NotifyPropertyChanged("s_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int p_id
			{
				get { return _p_id; }
				set { if (value != _p_id) { _p_id = value; NotifyPropertyChanged("p_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String s_author
			{
				get { return _s_author; }
				set { if (value != _s_author) { _s_author = value; NotifyPropertyChanged("s_author"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime s_date
			{
				get { return _s_date; }
				set { if (value != _s_date) { _s_date = value; NotifyPropertyChanged("s_date"); } }
			}
		};


		public class Item_Phenomenon : entity
		{
			public Item_Phenomenon(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _ip_id;
			[ExternalKey(typeof(Item))]
			int _i_id;
			[ExternalKey(typeof(Phenomenon))]
			int _p_id;
			string _ip_author;
			DateTime _ip_date;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int ip_id
			{
				get { return _ip_id; }
				set { if (value != _ip_id) { _ip_id = value; NotifyPropertyChanged("ip_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_id
			{
				get { return _i_id; }
				set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int p_id
			{
				get { return _p_id; }
				set { if (value != _p_id) { _p_id = value; NotifyPropertyChanged("p_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String ip_author
			{
				get { return _ip_author; }
				set { if (value != _ip_author) { _ip_author = value; NotifyPropertyChanged("ip_author"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime ip_date
			{
				get { return _ip_date; }
				set { if (value != _ip_date) { _ip_date = value; NotifyPropertyChanged("ip_date"); } }
			}
		};


		public class Item_Set : entity
		{
			public Item_Set(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Item))]
			int _i_id;
			[ExternalKey(typeof(Set))]
			int _s_id;
			int _polarity;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_id
			{
				get { return _i_id; }
				set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int s_id
			{
				get { return _s_id; }
				set { if (value != _s_id) { _s_id = value; NotifyPropertyChanged("s_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int polarity
			{
				get { return _polarity; }
				set { if (value != _polarity) { _polarity = value; NotifyPropertyChanged("polarity"); } }
			}
		};


		public class Run : entity
		{
			public Run(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _run_id;				// unique test run identifier
			string _run_comment;					// descriptive narrative
			string _platform;						// implementation platform (version)
			int _protocol;							// [incr tsdb()] protocol version
			string _tsdb;							// tsdb(1) (version) used
			string _application;					// application (version) used
			string _environment;					// application_specific information
			string _grammar;						// grammar (version) used
			int _avms;								// number of avm types in image
			int _sorts;								// number of sort types in image
			int _templates;							// number of templates in image
			int _lexicon;							// number of lexical entries
			int _lrules;							// number of lexical rules
			int _rules;								// number of (non_lexical) rules
			string _user;							// user who did the test run
			string _host;							// machine used for this run
			string _os;								// operating system (version)
			DateTime _start;						// start time of this test run
			DateTime _end;							// end time for this test run
			int _items;								// number of test items in this run
			string _status;							// exit status (PVM only)

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int run_id
			{
				get { return _run_id; }
				set { if (value != _run_id) { _run_id = value; NotifyPropertyChanged("run_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String run_comment
			{
				get { return _run_comment; }
				set { if (value != _run_comment) { _run_comment = value; NotifyPropertyChanged("run_comment"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String platform
			{
				get { return _platform; }
				set { if (value != _platform) { _platform = value; NotifyPropertyChanged("platform"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int protocol
			{
				get { return _protocol; }
				set { if (value != _protocol) { _protocol = value; NotifyPropertyChanged("protocol"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String tsdb
			{
				get { return _tsdb; }
				set { if (value != _tsdb) { _tsdb = value; NotifyPropertyChanged("tsdb"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String application
			{
				get { return _application; }
				set { if (value != _application) { _application = value; NotifyPropertyChanged("application"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String environment
			{
				get { return _environment; }
				set { if (value != _environment) { _environment = value; NotifyPropertyChanged("environment"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String grammar
			{
				get { return _grammar; }
				set { if (value != _grammar) { _grammar = value; NotifyPropertyChanged("grammar"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int avms
			{
				get { return _avms; }
				set { if (value != _avms) { _avms = value; NotifyPropertyChanged("avms"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int sorts
			{
				get { return _sorts; }
				set { if (value != _sorts) { _sorts = value; NotifyPropertyChanged("sorts"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int templates
			{
				get { return _templates; }
				set { if (value != _templates) { _templates = value; NotifyPropertyChanged("templates"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int lexicon
			{
				get { return _lexicon; }
				set { if (value != _lexicon) { _lexicon = value; NotifyPropertyChanged("lexicon"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int lrules
			{
				get { return _lrules; }
				set { if (value != _lrules) { _lrules = value; NotifyPropertyChanged("lrules"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int rules
			{
				get { return _rules; }
				set { if (value != _rules) { _rules = value; NotifyPropertyChanged("rules"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String user
			{
				get { return _user; }
				set { if (value != _user) { _user = value; NotifyPropertyChanged("user"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String host
			{
				get { return _host; }
				set { if (value != _host) { _host = value; NotifyPropertyChanged("host"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String os
			{
				get { return _os; }
				set { if (value != _os) { _os = value; NotifyPropertyChanged("os"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime start
			{
				get { return _start; }
				set { if (value != _start) { _start = value; NotifyPropertyChanged("start"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime end
			{
				get { return _end; }
				set { if (value != _end) { _end = value; NotifyPropertyChanged("end"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int items
			{
				get { return _items; }
				set { if (value != _items) { _items = value; NotifyPropertyChanged("items"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String status
			{
				get { return _status; }
				set { if (value != _status) { _status = value; NotifyPropertyChanged("status"); } }
			}
		};


		public class Parse : entity
		{
			public Parse(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _parse_id;						// unique parse identifier
			[ExternalKey(typeof(Run))]
			int _run_id;	// test run for this parse
			[ExternalKey(typeof(Item))]
			int _i_id;		// item parsed
			int _ninputs;									// number of initial tokens
			string _p_input;								// initial (pre_processed) parser input
			int _ntokens;									// number of internal tokens
			string _p_tokens;								// internal parser input: lexical lookup
			int _readings;									// number of readings obtained
			int _first;										// time to find first reading (msec)
			int _total;										// total time for parsing (msec)
			int _tcpu;										// total (cpu) processing time (msec)
			int _tgc;										// gc time used (msec)
			int _treal;										// overall real time (msec)
			int _words;										// lexical entries retrieved
			int _l_stasks;									// successful lexical rule applications
			int _p_ctasks;									// parser contemplated tasks (LKB)
			int _p_ftasks;									// parser filtered tasks
			int _p_etasks;									// parser executed tasks
			int _p_stasks;									// parser succeeding tasks
			int _aedges;									// active items in chart (PAGE)
			int _pedges;									// passive items in chart
			int _raedges;									// active items contributing to result
			int _rpedges;									// passive items contributing to result
			int _tedges;									// type-0 entries in (visible) forest
			int _eedges;									// type-1 entries in (visible) forest
			int _ledges;									// type-2 entries in (visible) forest
			int _sedges;									// type-3 entries in (visible) forest
			int _redges;									// type-4 entries in (visible) forest
			long _unifications;								// number of (node) unifications
			long _copies;									// number of (node) copy operations
			long _conses;									// cons() cells allocated
			long _symbols;									// symbols allocated
			long _others;									// bytes of memory allocated
			int _gcs;										// number of garbage collections
			int _i_load;									// initial load (start of parse)
			int _a_load;									// average load
			DateTime _date;									// date and time of parse
			string _error;									// error string (if applicable |:_)
			string _comment;								// application_specific comment

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int run_id
			{
				get { return _run_id; }
				set { if (value != _run_id) { _run_id = value; NotifyPropertyChanged("run_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_id
			{
				get { return _i_id; }
				set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int ninputs
			{
				get { return _ninputs; }
				set { if (value != _ninputs) { _ninputs = value; NotifyPropertyChanged("ninputs"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_input
			{
				get { return _p_input; }
				set { if (value != _p_input) { _p_input = value; NotifyPropertyChanged("p_input"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int ntokens
			{
				get { return _ntokens; }
				set { if (value != _ntokens) { _ntokens = value; NotifyPropertyChanged("ntokens"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String p_tokens
			{
				get { return _p_tokens; }
				set { if (value != _p_tokens) { _p_tokens = value; NotifyPropertyChanged("p_tokens"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int readings
			{
				get { return _readings; }
				set { if (value != _readings) { _readings = value; NotifyPropertyChanged("readings"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int first
			{
				get { return _first; }
				set { if (value != _first) { _first = value; NotifyPropertyChanged("first"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int total
			{
				get { return _total; }
				set { if (value != _total) { _total = value; NotifyPropertyChanged("total"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int tcpu
			{
				get { return _tcpu; }
				set { if (value != _tcpu) { _tcpu = value; NotifyPropertyChanged("tcpu"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int tgc
			{
				get { return _tgc; }
				set { if (value != _tgc) { _tgc = value; NotifyPropertyChanged("tgc"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int treal
			{
				get { return _treal; }
				set { if (value != _treal) { _treal = value; NotifyPropertyChanged("treal"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int words
			{
				get { return _words; }
				set { if (value != _words) { _words = value; NotifyPropertyChanged("words"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int l_stasks
			{
				get { return _l_stasks; }
				set { if (value != _l_stasks) { _l_stasks = value; NotifyPropertyChanged("l_stasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int p_ctasks
			{
				get { return _p_ctasks; }
				set { if (value != _p_ctasks) { _p_ctasks = value; NotifyPropertyChanged("p_ctasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int p_ftasks
			{
				get { return _p_ftasks; }
				set { if (value != _p_ftasks) { _p_ftasks = value; NotifyPropertyChanged("p_ftasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int p_etasks
			{
				get { return _p_etasks; }
				set { if (value != _p_etasks) { _p_etasks = value; NotifyPropertyChanged("p_etasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int p_stasks
			{
				get { return _p_stasks; }
				set { if (value != _p_stasks) { _p_stasks = value; NotifyPropertyChanged("p_stasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int aedges
			{
				get { return _aedges; }
				set { if (value != _aedges) { _aedges = value; NotifyPropertyChanged("aedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int pedges
			{
				get { return _pedges; }
				set { if (value != _pedges) { _pedges = value; NotifyPropertyChanged("pedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int raedges
			{
				get { return _raedges; }
				set { if (value != _raedges) { _raedges = value; NotifyPropertyChanged("raedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int rpedges
			{
				get { return _rpedges; }
				set { if (value != _rpedges) { _rpedges = value; NotifyPropertyChanged("rpedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int tedges
			{
				get { return _tedges; }
				set { if (value != _tedges) { _tedges = value; NotifyPropertyChanged("tedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int eedges
			{
				get { return _eedges; }
				set { if (value != _eedges) { _eedges = value; NotifyPropertyChanged("eedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int ledges
			{
				get { return _ledges; }
				set { if (value != _ledges) { _ledges = value; NotifyPropertyChanged("ledges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int sedges
			{
				get { return _sedges; }
				set { if (value != _sedges) { _sedges = value; NotifyPropertyChanged("sedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int redges
			{
				get { return _redges; }
				set { if (value != _redges) { _redges = value; NotifyPropertyChanged("redges"); } }
			}

			public long unifications
			{
				get { return _unifications; }
				set { if (value != _unifications) { _unifications = value; NotifyPropertyChanged("unifications"); } }
			}

			public long copies
			{
				get { return _copies; }
				set { if (value != _copies) { _copies = value; NotifyPropertyChanged("copies"); } }
			}

			public long conses
			{
				get { return _conses; }
				set { if (value != _conses) { _conses = value; NotifyPropertyChanged("conses"); } }
			}

			public long symbols
			{
				get { return _symbols; }
				set { if (value != _symbols) { _symbols = value; NotifyPropertyChanged("symbols"); } }
			}

			public long others
			{
				get { return _others; }
				set { if (value != _others) { _others = value; NotifyPropertyChanged("others"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int gcs
			{
				get { return _gcs; }
				set { if (value != _gcs) { _gcs = value; NotifyPropertyChanged("gcs"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_load
			{
				get { return _i_load; }
				set { if (value != _i_load) { _i_load = value; NotifyPropertyChanged("i_load"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int a_load
			{
				get { return _a_load; }
				set { if (value != _a_load) { _a_load = value; NotifyPropertyChanged("a_load"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime date
			{
				get { return _date; }
				set { if (value != _date) { _date = value; NotifyPropertyChanged("date"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String error
			{
				get { return _error; }
				set { if (value != _error) { _error = value; NotifyPropertyChanged("error"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String comment
			{
				get { return _comment; }
				set { if (value != _comment) { _comment = value; NotifyPropertyChanged("comment"); } }
			}
		};


		public class Result : entity
		{
			public Result(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Parse))]
			int _parse_id;		// parse for this result
			[PrimaryKey]
			int _result_id;							// unique result identifier
			int _time;												// time to find this result (msec)
			int _r_ctasks;											// parser contemplated tasks
			int _r_ftasks;											// parser filtered tasks
			int _r_etasks;											// parser executed tasks
			int _r_stasks;											// parser succeeding tasks
			int _size;												// size of feature structure
			int _r_aedges;											// active items for this result
			int _r_pedges;											// passive items in this result
			string _derivation;										// derivation tree for this reading
			string _surface;										// surface string (e.g. realization)
			string _tree;											// phrase structure tree (CSLI labels)
			string _mrs;											// mrs for this reading
			string _flags;											// arbitrary annotation (e.g. BLEU)

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int result_id
			{
				get { return _result_id; }
				set { if (value != _result_id) { _result_id = value; NotifyPropertyChanged("result_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int time
			{
				get { return _time; }
				set { if (value != _time) { _time = value; NotifyPropertyChanged("time"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int r_ctasks
			{
				get { return _r_ctasks; }
				set { if (value != _r_ctasks) { _r_ctasks = value; NotifyPropertyChanged("r_ctasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int r_ftasks
			{
				get { return _r_ftasks; }
				set { if (value != _r_ftasks) { _r_ftasks = value; NotifyPropertyChanged("r_ftasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int r_etasks
			{
				get { return _r_etasks; }
				set { if (value != _r_etasks) { _r_etasks = value; NotifyPropertyChanged("r_etasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int r_stasks
			{
				get { return _r_stasks; }
				set { if (value != _r_stasks) { _r_stasks = value; NotifyPropertyChanged("r_stasks"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int size
			{
				get { return _size; }
				set { if (value != _size) { _size = value; NotifyPropertyChanged("size"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int r_aedges
			{
				get { return _r_aedges; }
				set { if (value != _r_aedges) { _r_aedges = value; NotifyPropertyChanged("r_aedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int r_pedges
			{
				get { return _r_pedges; }
				set { if (value != _r_pedges) { _r_pedges = value; NotifyPropertyChanged("r_pedges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String derivation
			{
				get { return _derivation; }
				set { if (value != _derivation) { _derivation = value; NotifyPropertyChanged("derivation"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String surface
			{
				get { return _surface; }
				set { if (value != _surface) { _surface = value; NotifyPropertyChanged("surface"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String tree
			{
				get { return _tree; }
				set { if (value != _tree) { _tree = value; NotifyPropertyChanged("tree"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String mrs
			{
				get { return _mrs; }
				set { if (value != _mrs) { _mrs = value; NotifyPropertyChanged("mrs"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String flags
			{
				get { return _flags; }
				set { if (value != _flags) { _flags = value; NotifyPropertyChanged("flags"); } }
			}
		};


		public class Rule : entity
		{
			public Rule(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Parse))]
			int _parse_id;			// parse for this rule summary
			string _rule;												// rule name
			int _filtered;												// rule postulations filtered
			int _executed;												// rule postulations executed
			int _successes;												// successful rule postulations
			int _actives;												// active edges built from this rule
			int _passives;												// passive edges built from this rule

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String rule
			{
				get { return _rule; }
				set { if (value != _rule) { _rule = value; NotifyPropertyChanged("rule"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int filtered
			{
				get { return _filtered; }
				set { if (value != _filtered) { _filtered = value; NotifyPropertyChanged("filtered"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int executed
			{
				get { return _executed; }
				set { if (value != _executed) { _executed = value; NotifyPropertyChanged("executed"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int successes
			{
				get { return _successes; }
				set { if (value != _successes) { _successes = value; NotifyPropertyChanged("successes"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int actives
			{
				get { return _actives; }
				set { if (value != _actives) { _actives = value; NotifyPropertyChanged("actives"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int passives
			{
				get { return _passives; }
				set { if (value != _passives) { _passives = value; NotifyPropertyChanged("passives"); } }
			}
		};


		public class Output : entity
		{
			public Output(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Item))]
			int _i_id;				// item for this output specification
			string _o_application;									// applicable appliaction(s)
			string _o_grammar;										// applicable grammar(s)
			string _o_ignore;										// ignore this item flag
			int _o_wf;												// application_specific grammaticality
			int _o_gc;												// maximal number of garbage collections
			string _o_derivation;									// expected derivation
			string _o_surface;										// expected surface string
			string _o_tree;											// expected phrase structure tree
			string _o_mrs;											// expected mrs
			int _o_edges;											// maximal number of edges to build
			string _o_user;											// author of this output specification
			DateTime _o_date;										// creation date

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int i_id
			{
				get { return _i_id; }
				set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_application
			{
				get { return _o_application; }
				set { if (value != _o_application) { _o_application = value; NotifyPropertyChanged("o_application"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_grammar
			{
				get { return _o_grammar; }
				set { if (value != _o_grammar) { _o_grammar = value; NotifyPropertyChanged("o_grammar"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_ignore
			{
				get { return _o_ignore; }
				set { if (value != _o_ignore) { _o_ignore = value; NotifyPropertyChanged("o_ignore"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int o_wf
			{
				get { return _o_wf; }
				set { if (value != _o_wf) { _o_wf = value; NotifyPropertyChanged("o_wf"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int o_gc
			{
				get { return _o_gc; }
				set { if (value != _o_gc) { _o_gc = value; NotifyPropertyChanged("o_gc"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_derivation
			{
				get { return _o_derivation; }
				set { if (value != _o_derivation) { _o_derivation = value; NotifyPropertyChanged("o_derivation"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_surface
			{
				get { return _o_surface; }
				set { if (value != _o_surface) { _o_surface = value; NotifyPropertyChanged("o_surface"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_tree
			{
				get { return _o_tree; }
				set { if (value != _o_tree) { _o_tree = value; NotifyPropertyChanged("o_tree"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_mrs
			{
				get { return _o_mrs; }
				set { if (value != _o_mrs) { _o_mrs = value; NotifyPropertyChanged("o_mrs"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int o_edges
			{
				get { return _o_edges; }
				set { if (value != _o_edges) { _o_edges = value; NotifyPropertyChanged("o_edges"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String o_user
			{
				get { return _o_user; }
				set { if (value != _o_user) { _o_user = value; NotifyPropertyChanged("o_user"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime o_date
			{
				get { return _o_date; }
				set { if (value != _o_date) { _o_date = value; NotifyPropertyChanged("o_date"); } }
			}
		};


		public class Edge : entity
		{
			public Edge(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _e_id;								// unique edge identifier
			[ExternalKey(typeof(Parse))]
			int _parse_id;	// parse for this edge
			string _e_label;									// edge label (as in `derivation')
			int _e_type;										// item type for edge (0 -- 4)
			int _e_status;										//  bit-coded item flags  ( 0 : passive;1 : active ?)
			int _e_start;										// start vertex for this edge
			int _e_end;											// end vertex for this edge
			string _e_score;									// platform-specific figure of merit
			string _e_daughters;								// (Common_Lisp) list of daughters
			string _e_parents;									// (Common_Lisp) list of parents
			string _e_alternates;								// alternates packed into this edge

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int e_id
			{
				get { return _e_id; }
				set { if (value != _e_id) { _e_id = value; NotifyPropertyChanged("e_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String e_label
			{
				get { return _e_label; }
				set { if (value != _e_label) { _e_label = value; NotifyPropertyChanged("e_label"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int e_type
			{
				get { return _e_type; }
				set { if (value != _e_type) { _e_type = value; NotifyPropertyChanged("e_type"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int e_status
			{
				get { return _e_status; }
				set { if (value != _e_status) { _e_status = value; NotifyPropertyChanged("e_status"); } }
			}

			//[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			//public int e_result
			//{
			//	get { return _e_result; }
			//	set { if (value != _e_result) { _e_result = value; NotifyPropertyChanged("e_result"); } }
			//}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int e_start
			{
				get { return _e_start; }
				set { if (value != _e_start) { _e_start = value; NotifyPropertyChanged("e_start"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int e_end
			{
				get { return _e_end; }
				set { if (value != _e_end) { _e_end = value; NotifyPropertyChanged("e_end"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String e_score
			{
				get { return _e_score; }
				set { if (value != _e_score) { _e_score = value; NotifyPropertyChanged("e_score"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String e_daughters
			{
				get { return _e_daughters; }
				set { if (value != _e_daughters) { _e_daughters = value; NotifyPropertyChanged("e_daughters"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String e_parents
			{
				get { return _e_parents; }
				set { if (value != _e_parents) { _e_parents = value; NotifyPropertyChanged("e_parents"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String e_alternates
			{
				get { return _e_alternates; }
				set { if (value != _e_alternates) { _e_alternates = value; NotifyPropertyChanged("e_alternates"); } }
			}
		};


		public class Tree : entity
		{
			public Tree(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Parse))]
			int _parse_id;
			int _t_version;
			int _t_active;				// :key (2011-01-30 gcs ??)
			int _t_confidence;
			string _t_author;
			DateTime _t_start;
			DateTime _t_end;
			string _t_comment;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int t_version
			{
				get { return _t_version; }
				set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int t_active
			{
				get { return _t_active; }
				set { if (value != _t_active) { _t_active = value; NotifyPropertyChanged("t_active"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int t_confidence
			{
				get { return _t_confidence; }
				set { if (value != _t_confidence) { _t_confidence = value; NotifyPropertyChanged("t_confidence"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String t_author
			{
				get { return _t_author; }
				set { if (value != _t_author) { _t_author = value; NotifyPropertyChanged("t_author"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime t_start
			{
				get { return _t_start; }
				set { if (value != _t_start) { _t_start = value; NotifyPropertyChanged("t_start"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime t_end
			{
				get { return _t_end; }
				set { if (value != _t_end) { _t_end = value; NotifyPropertyChanged("t_end"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String t_comment
			{
				get { return _t_comment; }
				set { if (value != _t_comment) { _t_comment = value; NotifyPropertyChanged("t_comment"); } }
			}
		};


		public class Decision : entity
		{
			public Decision(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Parse))]
			int _parse_id;
			int _t_version;
			int _d_state;
			int _d_type;
			string _d_key;
			string _d_value;
			int _d_start;
			int _d_end;
			DateTime _d_date;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int t_version
			{
				get { return _t_version; }
				set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int d_state
			{
				get { return _d_state; }
				set { if (value != _d_state) { _d_state = value; NotifyPropertyChanged("d_state"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int d_type
			{
				get { return _d_type; }
				set { if (value != _d_type) { _d_type = value; NotifyPropertyChanged("d_type"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String d_key
			{
				get { return _d_key; }
				set { if (value != _d_key) { _d_key = value; NotifyPropertyChanged("d_key"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String d_value
			{
				get { return _d_value; }
				set { if (value != _d_value) { _d_value = value; NotifyPropertyChanged("d_value"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int d_start
			{
				get { return _d_start; }
				set { if (value != _d_start) { _d_start = value; NotifyPropertyChanged("d_start"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int d_end
			{
				get { return _d_end; }
				set { if (value != _d_end) { _d_end = value; NotifyPropertyChanged("d_end"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime d_date
			{
				get { return _d_date; }
				set { if (value != _d_date) { _d_date = value; NotifyPropertyChanged("d_date"); } }
			}
		};


		public class Preference : entity
		{
			public Preference(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Parse))]
			int _parse_id;
			int _t_version;
			[ExternalKey(typeof(Result))]
			int _result_id;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int t_version
			{
				get { return _t_version; }
				set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int result_id
			{
				get { return _result_id; }
				set { if (value != _result_id) { _result_id = value; NotifyPropertyChanged("result_id"); } }
			}
		};


		public class Update : entity
		{
			public Update(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Parse))]
			int _parse_id;
			int _t_version;
			int _u_matches;
			int _u_mismatches;
			int _u_new;
			int _u_gin;
			int _u_gout;
			int _u_pin;
			int _u_pout;
			int _u_in;
			int _u_out;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int t_version
			{
				get { return _t_version; }
				set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_matches
			{
				get { return _u_matches; }
				set { if (value != _u_matches) { _u_matches = value; NotifyPropertyChanged("u_matches"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_mismatches
			{
				get { return _u_mismatches; }
				set { if (value != _u_mismatches) { _u_mismatches = value; NotifyPropertyChanged("u_mismatches"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_new
			{
				get { return _u_new; }
				set { if (value != _u_new) { _u_new = value; NotifyPropertyChanged("u_new"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_gin
			{
				get { return _u_gin; }
				set { if (value != _u_gin) { _u_gin = value; NotifyPropertyChanged("u_gin"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_gout
			{
				get { return _u_gout; }
				set { if (value != _u_gout) { _u_gout = value; NotifyPropertyChanged("u_gout"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_pin
			{
				get { return _u_pin; }
				set { if (value != _u_pin) { _u_pin = value; NotifyPropertyChanged("u_pin"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_pout
			{
				get { return _u_pout; }
				set { if (value != _u_pout) { _u_pout = value; NotifyPropertyChanged("u_pout"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_in
			{
				get { return _u_in; }
				set { if (value != _u_in) { _u_in = value; NotifyPropertyChanged("u_in"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int u_out
			{
				get { return _u_out; }
				set { if (value != _u_out) { _u_out = value; NotifyPropertyChanged("u_out"); } }
			}
		};


		public class Fold : entity
		{
			public Fold(TsdbTable tb) : base(tb) { }

			[PrimaryKey]
			int _f_id;
			int _f_train;
			string _f_trains;
			int _f_test;
			string _f_tests;
			int _f_events;
			int _f_features;
			string _f_environment;
			int _f_iterations;
			int _f_etime;
			string _f_estimation;
			string _f_accuracy;
			string _f_extras;
			string _f_user;
			string _f_host;
			DateTime _f_start;
			DateTime _f_end;
			string _f_comment;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int f_id
			{
				get { return _f_id; }
				set { if (value != _f_id) { _f_id = value; NotifyPropertyChanged("f_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int f_train
			{
				get { return _f_train; }
				set { if (value != _f_train) { _f_train = value; NotifyPropertyChanged("f_train"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_trains
			{
				get { return _f_trains; }
				set { if (value != _f_trains) { _f_trains = value; NotifyPropertyChanged("f_trains"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int f_test
			{
				get { return _f_test; }
				set { if (value != _f_test) { _f_test = value; NotifyPropertyChanged("f_test"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_tests
			{
				get { return _f_tests; }
				set { if (value != _f_tests) { _f_tests = value; NotifyPropertyChanged("f_tests"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int f_events
			{
				get { return _f_events; }
				set { if (value != _f_events) { _f_events = value; NotifyPropertyChanged("f_events"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int f_features
			{
				get { return _f_features; }
				set { if (value != _f_features) { _f_features = value; NotifyPropertyChanged("f_features"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_environment
			{
				get { return _f_environment; }
				set { if (value != _f_environment) { _f_environment = value; NotifyPropertyChanged("f_environment"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int f_iterations
			{
				get { return _f_iterations; }
				set { if (value != _f_iterations) { _f_iterations = value; NotifyPropertyChanged("f_iterations"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int f_etime
			{
				get { return _f_etime; }
				set { if (value != _f_etime) { _f_etime = value; NotifyPropertyChanged("f_etime"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_estimation
			{
				get { return _f_estimation; }
				set { if (value != _f_estimation) { _f_estimation = value; NotifyPropertyChanged("f_estimation"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_accuracy
			{
				get { return _f_accuracy; }
				set { if (value != _f_accuracy) { _f_accuracy = value; NotifyPropertyChanged("f_accuracy"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_extras
			{
				get { return _f_extras; }
				set { if (value != _f_extras) { _f_extras = value; NotifyPropertyChanged("f_extras"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_user
			{
				get { return _f_user; }
				set { if (value != _f_user) { _f_user = value; NotifyPropertyChanged("f_user"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_host
			{
				get { return _f_host; }
				set { if (value != _f_host) { _f_host = value; NotifyPropertyChanged("f_host"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime f_start
			{
				get { return _f_start; }
				set { if (value != _f_start) { _f_start = value; NotifyPropertyChanged("f_start"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public DateTime f_end
			{
				get { return _f_end; }
				set { if (value != _f_end) { _f_end = value; NotifyPropertyChanged("f_end"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String f_comment
			{
				get { return _f_comment; }
				set { if (value != _f_comment) { _f_comment = value; NotifyPropertyChanged("f_comment"); } }
			}
		};


		public class Score : entity
		{
			public Score(TsdbTable tb) : base(tb) { }

			[ExternalKey(typeof(Parse))]
			int _parse_id;
			[ExternalKey(typeof(Result))]
			int _result_id;
			int _score_start;
			int _score_end;
			[PrimaryKey]
			int _score_id;
			string _learner;
			int _rank;
			string _score;

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int parse_id
			{
				get { return _parse_id; }
				set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int result_id
			{
				get { return _result_id; }
				set { if (value != _result_id) { _result_id = value; NotifyPropertyChanged("result_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int score_start
			{
				get { return _score_start; }
				set { if (value != _score_start) { _score_start = value; NotifyPropertyChanged("score_start"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int score_end
			{
				get { return _score_end; }
				set { if (value != _score_end) { _score_end = value; NotifyPropertyChanged("score_end"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int score_id
			{
				get { return _score_id; }
				set { if (value != _score_id) { _score_id = value; NotifyPropertyChanged("score_id"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String learner
			{
				get { return _learner; }
				set { if (value != _learner) { _learner = value; NotifyPropertyChanged("learner"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public int rank
			{
				get { return _rank; }
				set { if (value != _rank) { _rank = value; NotifyPropertyChanged("rank"); } }
			}

			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			public String score
			{
				get { return _score; }
				set { if (value != _score) { _score = value; NotifyPropertyChanged("score"); } }
			}
		};
	};
}
